$(function(){
	$("#allHeader").load("data/header.php");
});

$("#dologin").on("click",function(){
	var $email = $("#user_email").val();
	var $upwd = $("#user_pwd").val();

	// var s = document.createElement('script');
	// s.async = true;
	// s.src = "http://127.0.0.1/yanxuan/data/login.php?callback=doResponse";
	// document.head.appendChild(s);

	// function doResponse(data){
	// 	console.log("服务器端开始处理响应数据");
	// 	console.log(data);
	// }
	var xhr = new XMLHttpRequest();
       //2
    xhr.onreadystatechange = function(){
	    if(xhr.readyState===4&&xhr.status===200){
	            //响应完成且成功
	        doResponse(xhr);
	    }
    }
    xhr.open('GET','data/user_login.php?email='+$email+'&upwd='+$upwd, true);
    xhr.send(null);
    function doResponse(xhr){   //处理响应消息
        console.log('开始处理响应消息');
        console.log(xhr);
        if(xhr.responseText==='yes'){
        	window.location.href="index.html";
        	$(".login").css("display","none");
        	sessionStorage.setItem("email",$email);
        }else if(xhr.responseText==='no'){
            $("#nerror").css("display","block");
        }
    }
});